<template>
	<view>
		<view class="inputs">
			<image src="/static/icon-search.png" style="width: 40rpx;height: 40rpx;" mode=""></image>
			<input type="text" placeholder="搜索学校" />
		</view>

		<view class="choosetxt">
			当前选择：{{moren}}
		</view>

		<scroll-view scroll-y="true" :style="{ height: windowHeight }" @scrolltolower="onreachBottom1">
			<view class="itembox" v-for="(item,index) in list" :key="index" @click="choose(item)">
				<image :src="item.avatar" style="width: 80rpx;height: 80rpx;border-radius: 50%;" mode=""></image>
				<view class="title_txt">
					{{item.agent_area}} 
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	var app = getApp( );
	import ikz from '@/pages/Common/tools.js'
	export default {
		data( ) {
			return {
				windowHeight: 0,
				list:[],
				moren:''
			};
		},
		onLoad( ) {
			var _this = this
			uni.getSystemInfo( {
				success: function( res ) {
					console.log(res.windowHeight,'sssssssss');
					_this.windowHeight = res.windowHeight - 108 + 'px';
					console.log(_this.windowHeight,'_this.windowHeight ');
				}
			} )
		},
		onShow() {
			this.getshoose() 
			this.moren = uni.getStorageSync('default_agent').title
		},
		methods: {
			getshoose(){
				var path = '/xyb/user/baseinfo';
				var data = {};
				ikz.get( path, data, res => {
					console.log(res,'首页学校');
					if ( res.statusCode == 200 ) {
						this.list= res.data.data.agent_list
						// this.moren= res.data.data.user_info.agent_area
					} else {
						uni.showModal( {
							title: '提示',
							content: '服务器繁忙，请稍后再试',
							showCancel: false,
							success: function( res ) {}
						} );
					}
				
				} );
			},
			choose(item){
				console.log(item,'iii');
				const default_agent = {
					id:item.id,
					title:item.agent_area
				}
				uni.setStorageSync('default_agent', default_agent);
				app.globalData.default_agent = item.agent_area;
				this.moren = item.agent_area
				
				uni.switchTab({
					url:'/pages/Home/index'
				})
			}
		},
	}
</script>

<style lang="scss">
	page {
		padding: 22rpx 30rpx;
		box-sizing: border-box;
	}

	.inputs {
		width: 690rpx;
		height: 72rpx;
		background: #F7F7F7;
		border-radius: 30rpx 30rpx 30rpx 30rpx;
		display: flex;
		align-items: center;
		padding: 0 20rpx;
		box-sizing: border-box;

	}

	.choosetxt {
		width: 100%;
		height: 96rpx;
		padding: 0 30rpx;
		box-sizing: border-box;
		border-bottom: 2rpx solid #F5F5F5;
		font-weight: 500;
		font-size: 28rpx;
		color: #000000;
		line-height: 96rpx;
		text-align: left;
	}
	
	.itembox{
		width: 100%;
		height: 140rpx;
		display: flex;
		align-items: center;
		
		.title_txt{
			margin-left: 16rpx;
			font-weight: 500;
			font-size: 32rpx;
			color: #000000;
			text-align: left;
		}
	}
</style>